import request from '../../utils/request';

// 附件管理相关 API

// 创建附件
export const createAttachment = (data: any) => {
    return request({
        url: '/system/api/attachment',
        method: 'post',
        data
    });
};

// 批量创建附件
export const batchCreateAttachment = (data: any) => {
    return request({
        url: '/system/api/attachment/batch',
        method: 'post',
        data
    });
};

// 分页查询附件
export const getAttachmentPage = (params: any) => {
    return request({
        url: '/system/api/attachment/page',
        method: 'get',
        params
    });
};

// 获取附件列表
export const getAttachmentList = () => {
    return request({
        url: '/system/api/attachment/list',
        method: 'get'
    });
};

// 根据MD5获取附件
export const getAttachmentByMd5 = (md5: string) => {
    return request({
        url: `/system/api/attachment/getByMd5/${md5}`,
        method: 'get'
    });
};

// 根据数据类型和数据ID获取附件
export const getAttachmentByDataType = (dataType: string, dataId: string) => {
    return request({
        url: `/system/api/attachment/getAttachment/${dataType}/${dataId}`,
        method: 'get'
    });
};

// 根据数据类型、数据ID和附件类型获取附件
export const getAttachmentByType = (dataType: string, dataId: string, attachmentType: string) => {
    return request({
        url: `/system/api/attachment/getAttachment/${dataType}/${dataId}/${attachmentType}`,
        method: 'get'
    });
};

// 根据数据ID获取附件
export const getAttachmentByDataId = (dataId: string) => {
    return request({
        url: `/system/api/attachment/getAttachment/${dataId}`,
        method: 'get'
    });
};

// 检查附件是否存在
export const checkAttachmentExists = (md5: string) => {
    return request({
        url: `/system/api/attachment/exists/${md5}`,
        method: 'get'
    });
};

// 根据数据ID获取附件数据
export const getAttachmentData = (dataId: string) => {
    return request({
        url: `/system/api/attachment/data/${dataId}`,
        method: 'get'
    });
};
